<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<link href="<c:url value='/admin/css/custom.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/admin/css/style.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/mask.js'/>"></script>
<style type="text/css">
<!--
body {
	background: #ffffff;
	margin-top:10px;
	margin-left:5px;
	margin-right:5px;
}
-->
</style>
<script type="text/javascript">

</script>
<body>
<div class="EpmsMainTitle">
<p>会员管理</P>
</div>
<div class="EpmsInall">
<div class="EpmsSubTitle"><p><b>查询条件</b></p>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
<form action="userlist.action" method="post" >
	<tr>
    <td width="10%" class="EpmsTdWithColor">
    	<span class="portlet-section-header">会员ID</span></td>
	<td width="25%" class="EpmsTdNoColor">
	 	<input type="text" name="user.userAccount" value=""  id="projectName" class=inputInput/>
	</td> 
    <td width="10%" class="EpmsTdWithColor">
    	<span class="portlet-section-header">会员状态</span></td> 
	<td width="25%" class="EpmsTdNoColor" >
		<select name="user.activity" class=inputInput style="WIDTH: 120px"  id="select">
		<option value="">全部</option>
	  		<option value="0" >已激活</option>
        	<option value="1">未激活</option>
	    </select>
	</td>
	<input type="hidden" id="entertype" value="${user.enterType}"/>
	<!-- <td width="10%" class="EpmsTdWithColor">
    	<span class="portlet-section-header">会员状态</span></td> 
	<td width="25%" class="EpmsTdNoColor" >
		<select name="user.role" class=inputInput style="WIDTH: 120px"  id="select">
		<option value="">全部</option>
	  		<option value="0" >公司账户</option>
        	<option value="1">普通账户</option>
	    </select>
	</td> -->
	<%-- <td width="10%" class="EpmsTdWithColor">
    	<span class="portlet-section-header">级别</span></td> 
	<td width="15%" class="EpmsTdNoColor" >
		<select name="user.level" class=inputInput style="WIDTH: 120px"  id="select">
			<option value="">全部</option>
	  		<c:forEach var="levels" items="${levelList}">
	  			<option value="${levels.code}">${levels.name}</option>
	  		</c:forEach>
	    </select>
	</td> --%>
		<td class="EpmsTdNoColor" align="center">
			<div class="EpmsButtonDiv">&nbsp;
			  <input type="submit" name="button" id="querybtn" value="查询" class="inputSubmit" />
			  <input type="reset" name="button" id="button" value="清空" class="inputSubmit" />
			</div>
		</td>
    </tr>
    <tr>
    	<td class="EpmsTdNoColor" colspan="5" align="left">
    		<input type="button" id="markUserType" name="markUserType" value="标记为公司账户"/>&nbsp;
    		<input type="button" id="unmarkUserType" name="unmarkUserType" value="取消标示"/>
    	</td>
    </tr>
  	<%-- <tr>
	    <td width="10%" class="EpmsTdWithColor">
	    <span class="portlet-section-header">推荐人</span></td>
	    <td width="23%" class="EpmsTdNoColor">
	    	<input type="text" id="rep" name="user.recommendId" class="inputInput" value="${user.recommendId}"/>
	    </td>	
		<td width="10%" class="EpmsTdWithColor">
		<span class="portlet-section-header">安置人</span></td>
	    <td width="23%" class="EpmsTdNoColor">
	   		<input type="text" name="user.parentId" id="" value="${user.parentId }" class="inputInput"/>
	    </td>
	    <td width="10%" class="EpmsTdWithColor"></td>
	    <td width="23%" class="EpmsTdNoColor">
	    </td>	
    </tr> --%>
</form>
</table>

<div class="EpmsSubTitle"><p><b>会员列表</b></p>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="EpmsTable">
  <tr>
	  <td class=EpmsTdTitle>标记</td>
	  <td class=EpmsTdTitle>会员类型</td>
	  <td class=EpmsTdTitle>会员账户</td>
	  <td class=EpmsTdTitle>推荐人</td>
	  <td class=EpmsTdTitle>安置人</td>
	  <td class=EpmsTdTitle>区域</td>
	  <td class=EpmsTdTitle>级别</td>
	  <!-- <td class=EpmsTdTitle>注册时间</td> -->
	  <td class=EpmsTdTitle>激活时间</td>
	  <td class=EpmsTdTitle>状态</td>
	  <td class=EpmsTdTitle>财务管理</td>
	 <!--  <td class=EpmsTdTitle>总账</td> -->
	  <td class=EpmsTdTitle>前台</td>
	  <td class=EpmsTdTitle>操作</td>
  </tr>
  <form action="" id="markForm" method="post">
	<c:forEach var="user" items="${page.result }" varStatus="status">
		<tr>
			<td class=EpmsTdNoColor>
				<input type="checkbox" name="userIds" value="${user.userId}" <c:if test="${user.role eq '3'}">checked</c:if>/>
			</td>
			<td class=EpmsTdNoColor>
				<c:choose>
					<c:when test="${user.role eq '1' || user.role eq '3'}">公司账户</c:when>
					<c:otherwise>普通账户</c:otherwise>
				</c:choose>
			</td>
		    <td class=EpmsTdNoColor >${user.userAccount }</td>
		    <td class=EpmsTdNoColor >${user.recommendId }</td>
			<td class=EpmsTdNoColor >${user.parentId }</td>
			<td class=EpmsTdNoColor >
				<c:forEach var="loc" items="${locationList}">
	  				<c:if test="${loc.code eq user.location}">${loc.name}</c:if>
	  			</c:forEach>
			</td>
		    <td class=EpmsTdNoColor >
		    	<c:forEach var="levels" items="${levelList}">
	  				<c:if test="${levels.code eq user.level}">${levels.name}</c:if>
	  			</c:forEach>
		    </td> 
			<%-- <td class=EpmsTdNoColor>
				<fmt:formatDate value="${user.registerDate}" pattern="yyyy-M-dd HH:mm:ss"/>
			</td> --%>
			<td class=EpmsTdNoColor>${user.activityDate } &nbsp;</td>
		    <td class=EpmsTdNoColor>
		    	<c:choose>
		    		<c:when test="${'0' eq user.activity}"><font color="green">已激活</font></c:when>
		    		<c:otherwise><font color="red">未激活</font></c:otherwise>
		    	</c:choose>
		    </td>
			<td class=EpmsTdNoColor align="center">
				<a href="${ctx}/admin/useraccount.action?account=${user.userAccount}" target="_blank">账户</a>
				<a href="${ctx}/admin/charge.action?account=${user.userAccount}">充值/扣款</a>
			</td>
			<td class=EpmsTdNoColor align="center">
				<a href="enter.action?username=${user.userAccount}&password=${user.firstPwd}" target="_blank">进入</a>
			</td>
			<td class=EpmsTdNoColor align="center">
				<a href="${ctx}/admin/toupdatepwd.action?userId=${user.userId}">修改密码</a>
				<a href="${ctx}/admin/toupdatebank.action?account=${user.userAccount}">修改银行帐号</a>
			</td>
		</tr>
	</c:forEach>
	</form>
	<tr>
		<td class="EpmsTdNoColor" colspan="12" align="right">
		第${page.pageNo}页&nbsp;&nbsp;
			<c:choose>
			<c:when test="${page.pageNo >1}">
				<a href="javascript:void(0);" style="text-decoration: none;">
					<span onclick="frontpage(${page.pageNo-1})">上一页</span>&nbsp;
				</a>
			</c:when>
			<c:otherwise>
				上一页 &nbsp;
			</c:otherwise>
			</c:choose>
			<c:choose>
				<c:when test="${page.totalPageCount > page.pageNo}">	
					<a href="javascript:void(0);" style="text-decoration: none;">
						<span onclick="nextpage(${page.pageNo+1})">下一页</span> &nbsp;
					</a>
				</c:when>
				<c:otherwise>
					下一页&nbsp;
				</c:otherwise>
			</c:choose>
			&nbsp;共${page.totalPageCount }页&nbsp;&nbsp;&nbsp;共${page.totalCount}条
		</td>
	</tr>
</table>
</div>
</body>
<script type="text/javascript">
$("#markUserType").click(function(){
	var userx = $("input[name=userIds]").filter(":checked");
	if(userx.size() == 0){
		alert("请选择用户后操作。");
		return;
	}
	//alert(JSON.stringify(userx));  
	var data = $("#markForm").serialize();
    $(document).mask("系统处理中，请稍后......");
    jQuery.ajax({
		url: "${ctx}/admin/markuser.action?type=1",
		type: "post",
		dataType:"html",
		data: data,
		async:false,
		success: function(jsondata){
			alert(jsondata);
			window.location.href = "${ctx}/admin/userlist.action";
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
	    }
	});
	/* var userids = "";
	userx.each(function(){
		userids = userids + "," + $(this).val();
	});
	if(window.confirm("确认进行此操作吗？")){
		var form = $("#stockSBForm");
		form.attr("action","sale2.action?userids="+userids);
		form[0].submit();
	} */
});

$("#unmarkUserType").click(function(){
	var userx = $("input[name=userIds]").filter(":checked");
	if(userx.size() == 0){
		alert("请选择用户后操作。");
		return;
	}
	//alert(JSON.stringify(userx));  
	var data = $("#markForm").serialize();
    $(document).mask("系统处理中，请稍后......");
    jQuery.ajax({
		url: "${ctx}/admin/markuser.action?type=2",
		type: "post",
		dataType:"html",
		data: data,
		async:false,
		success: function(jsondata){
			alert(jsondata);
			window.location.href = "${ctx}/admin/userlist.action";
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
	    }
	});
});

function entermember(name, pwd){
	window.open('enter.action?username='+name+'&password='+pwd,'_blank');
}
function frontpage(pageNo){
	if($("#entertype").val() == '2'){
		window.location.href = "${ctx}/admin/userlist.action?pageNo="+pageNo+"&user.enterType=2";
	}else{
		window.location.href = "${ctx}/admin/userlist.action?pageNo="+pageNo;
	}
}

function nextpage(pageNo){
	if($("#entertype").val() == '2'){
		window.location.href = "${ctx}/admin/userlist.action?pageNo="+pageNo+"&user.enterType=2";
	}else{
		window.location.href = "${ctx}/admin/userlist.action?pageNo="+pageNo;
	}
}
</script>